using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using Rhizome.Contract;
using Rhizome.Contract.Diag;
using Rhizome.Internal;
using Rhizome.Model;

namespace Rhizome.Bindings
{
	public abstract class BindingProxy : RhizomeElement, INotifyPropertyChanged, IValidate
	{
		/// <summary>
		/// CLR Property name
		/// </summary>
		public string Property { get; private set; }

		protected object Plant
		{
			[DebuggerStepThrough]
			get { return GetValue(PlantProperty); }
		}

		/// <summary>
		/// Gets Property type
		/// </summary>
		public abstract Type Type { get; }

		protected BindingProxy(string property)
		{
			Property = property;
		}

		#region INotifyPropertyChanged Members

		public abstract event PropertyChangedEventHandler PropertyChanged;

		#endregion

		public abstract object Value { get; set; }

		public static BindingProxy Create(string property)
		{
			return new ReflectionBindingProxy(property);
		}

		#region Implementation of IValidate

		public abstract IEnumerable<IValidationResult> GetValidationResults();

		#endregion
	}
}